<template>
  <div class="page-content-container">
    <h1>FormulaEditor 公式编辑器</h1>
    <p>常用于表单内数据编辑</p>
    <h2>基础用法</h2>
    <demo-block height="400">
      <template #main>
        <rt-formula-editor ref="fe" v-model="formula" :variableOptions="options" filterable></rt-formula-editor>
        <!-- <el-button @click="look">查看</el-button> -->
      </template>
      <template #codes>
        <pre v-highlightjs>
          <code class="html">{{ codehtml }}</code>
          <code class="javascript">{{ code }}</code>
        </pre>
      </template>
    </demo-block>
    <h2>Attributes</h2>
    <el-table :data="attrTableData" style="width: 100%">
      <el-table-column prop="arg" label="参数" width="180">
      </el-table-column>
      <el-table-column prop="des" label="说明">
      </el-table-column>
      <el-table-column prop="type" label="类型" width="150">
      </el-table-column>
      <el-table-column prop="selector" label="可选值">
      </el-table-column>
      <el-table-column prop="default" label="默认值">
      </el-table-column>
    </el-table>
    <h2>Events</h2>
    <el-table :data="eventTableData" style="width: 100%">
      <el-table-column prop="name" label="事件名称" width="180">
      </el-table-column>
      <el-table-column prop="des" label="说明">
      </el-table-column>
      <el-table-column prop="arg" label="回调参数" width="150">
      </el-table-column>
    </el-table>
    <h2>Methods</h2>
    <el-table :data="methodTableData" style="width: 100%">
      <el-table-column prop="name" label="方法名" width="180">
      </el-table-column>
      <el-table-column prop="des" label="说明">
      </el-table-column>
      <el-table-column prop="arg" label="参数" width="150">
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      formula: [],
      options: [
        { label: "option1", value: "option1" },
        { label: "option2", value: "option2" },
        {
          label: "option3", value: "option3", children: [
            { label: "option3_1", value: "option3_1" },
            { label: "option3_2", value: "option3_2" },
            { label: "option3_3", value: "option3_3" },
          ]
        },
      ],
      codehtml: `<rt-formula-editor v-model="formula" :variableOptions="options"></rt-formula-editor>`,
      code:
        `export default {
  data() {
    return {
      formula: [],
      options: [
        { label: "option1", value: "option1" },
        { label: "option2", value: "option2" },
        {
          label: "option3", value: "option3", children: [
            { label: "option3_1", value: "option3_1" },
            { label: "option3_2", value: "option3_2" },
            { label: "option3_3", value: "option3_3" },
          ]
        },
      ],
    }
  }
}`,
      attrTableData: [
        {
          arg: 'value/v-model',
          des: '绑定值',
          type: 'Array',
          selector: ' — ',
          default: ' — '
        },
        {
          arg: 'variableOptions',
          des: '变量值数据源',
          type: 'Array',
          selector: ' — ',
          default: ' — '
        },
        {
          arg: 'filterable',
          des: '变量是否可搜索选项',
          type: 'Boolean',
          selector: ' — ',
          default: 'false'
        }
      ],
      eventTableData: [
        {
          name: 'change',
          des: '绑定之发生变化时触发',
          arg: '当前值',
        },
        {
          name: 'clear',
          des: '清空值时触发',
          arg: ' — ',
        },
      ],
      methodTableData: [
        {
          name: 'getStrResult',
          des: '获取字符串类型的表示式',
          arg: ' — ',
        },
      ],
    }
  },
  methods: {
    // look() {
    //   let result = this.$refs.fe.getStrResult()
    //   console.log(result)
    // }
  },
}

</script>


<style scoped>
p {
  font-size: 15px;
}
</style>